﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DepositChange.aspx.cs" Inherits="H2.NET.Web.Pages.SMD.DepositChange" %>

<%@ Import Namespace="H2.NET.Common" %>
<%@ Register Src="../../Controls/DwzAssessment.ascx" TagName="DwzAssessment" TagPrefix="uc" %>
<%@ Register Src="../../Controls/DwzAssessmentList.ascx" TagName="DwzAssessmentList" TagPrefix="uc" %>
<%@ Register Src="../../Controls/AjaxUpload.ascx" TagName="ajaxUpload" TagPrefix="uc" %>
<%@ Register Src="uc_dealer.ascx" TagName="uc_dealer" TagPrefix="uc" %>
<%@ Register Src="uc_head.ascx" TagName="uc_head" TagPrefix="uc1" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE10" />
<head id="Head1" runat="server">
    <title><%=GetCache(TaskAPI.Process)%></title>
    <link href="<%=Page.ResolveUrl("~/Resource/Css/Style.css")%>" type="text/css" rel="stylesheet" />
    <link href="<%=Page.ResolveUrl("~/Resource/jBox/Blue/jbox.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%=Page.ResolveUrl("~/Resource/Css/validform.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%=Page.ResolveUrl("~/Resource/qtip/jquery.qtip.min.css")%>" rel="stylesheet" type="text/css" />
    <script src="<%=Page.ResolveUrl("~/Resource/dwz/js/jquery-1.7.2.min.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/Js/Common.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/Js/jquery.money.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/jBox/jquery.jBox-2.3.min.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/jBox/jquery.jBox-zh-CN.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/Js/Validform_v5.3.2.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/My97DatePicker/WdatePicker.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/qtip/jquery.qtip.min.js")%>" type="text/javascript"></script>

    <style type="text/css">
        .out_groupTable input[type=text] {
            width: 90px;
        }
        input::-ms-clear{display:none;}
    </style>
    <script type="text/javascript">
        $(function () {
            /* 初始化相关样式、表单验证提示 st */
            $("[datatype='*']").after("<em class='required'>*</em>");
            $("#form1").Validform({
                //提示信息将只会在表单提交时触发显示
                tipSweep: true,
                tiptype: function (msg, o, cssctl) {
                    if (o.type == 3) {
                        $.jBox.tip(msg, 'info');
                    }
                }
            });
            /* 初始化相关样式、表单验证提示 ed */

            /* 初始化控件提示 st */
            $.ajax({
                type: 'POST',
                url: '<%=Page.ResolveUrl("~/pages/smd/ajaxtools/handler.ashx?action=get_tips")%>',
                data: { pagename: 'depositchange.aspx' },
                dataType: "json",
                cache: false,
                success: function (json) {
                    for (var o in json) {
                        var ControlID = json[o].ControlID;
                        var Content = json[o].Content;
                        $("#" + ControlID).qtip({
                            content: Content
                        });
                    }
                }
            });
            /* 初始化控件提示 ed */

            /* 初始化控件提示 st */
            $.ajax({
                type: 'POST',
                url: '<%=Page.ResolveUrl("~/pages/smd/ajaxtools/handler.ashx?action=get_tips")%>',
                data: { pagename: 'depositchange.aspx' },
                dataType: "json",
                cache: false,
                success: function (json) {
                    for (var o in json) {
                        var ControlID = json[o].ControlID;
                        var Content = json[o].Content;
                        $("#" + ControlID).qtip({
                            content: Content
                        });
                    }
                }
            });
            /* 初始化控件提示 ed */

            $(".groupTable").tableGroup({ groupColumn: 1 });

            /* 填写了退至客户银行账号，请默认勾选上“财务确认” */
            $(".out_groupTable :text.isFinanceConfirm").keyup(function () {
                $("#cb_isFinanceConfirm").removeAttr("checked");
                $("#cb_isFinanceConfirm").removeAttr("onclick");
                $(".out_groupTable :text.isFinanceConfirm").each(function () {
                    if (parseFloat($(this).val()) > 0) {
                        $("#cb_isFinanceConfirm").attr("checked", true);
                        $("#cb_isFinanceConfirm").attr("onclick", "return false");
                    }
                });
            });


        });

        //function empty(event) {
        //    $("#cb_isFinanceConfirm").removeAttr("checked");
        //    $("#cb_isFinanceConfirm").removeAttr("onclick");

        //    if (parseFloat($(event).val()) > 0) {
        //        $("#cb_isFinanceConfirm").attr("checked", true);
        //        $("#cb_isFinanceConfirm").attr("onclick", "return false");
        //    }

        //}

        /* 提交表单 st */
        function confirmSubmit() {
            if (window.confirm("确认要提交吗？")) {

                // 数据验证
                var in_id = $("#uc_dealer_in_dealer_id").val();
                var out_id = $("#uc_dealer_out_dealer_id").val();

                if (in_id == "" && out_id == "") {
                    $.jBox.tip("请选择进款经销商或者退款经销商", 'info');
                    return false;
                }

                $.jBox.tip('正在处理，请稍等...', 'loading');
                return true;
            }
            return false;
        }
        /* 提交表单 ed */

        /* 退款经销商回调方法 st */
        function dealerOutCallBack(dealerId) {
            $.jBox.tip('正在加载门店信息，请稍等...', 'loading');
            $.ajax({
                type: 'POST',
                url: '<%=Page.ResolveUrl("~/pages/smd/ajaxtools/handler.ashx?action=get_deposit_by_dealer")%>',
                data: { dealerid: dealerId },
                dataType: "json",
                cache: false,
                success: function (json) {
                    var html = "";
                    var i = 0;
                    for (var o in json) {
                        html += "<tr>"
                            + "     <td align='center' style='display:none'>[" + IsNull(json[o].AuthID) + "]" + IsNull(json[o].StoreName) + "</td>"
                            + "     <td align='center' style='width:40px;'>"
                            + "         <input type='checkbox' name='out_checked[" + i + "]' checked='checked' value='" + i + "' />"
                            + "         <input type='hidden' name='out_AuthID[" + i + "]' value='" + IsNull(json[o].AuthID) + "' />"
                            + "         <input type='hidden' name='out_StoreID[" + i + "]' value='" + IsNull(json[o].StoreID) + "' />"
                            + "         <input type='hidden' name='out_DeviceID[" + i + "]' value='" + IsNull(json[o].DeviceID) + "' />"
                            + "     </td>"
                            + "     <td align='center' style='padding:0 5px;'>" + (IsNull(json[o].FullSetSN)) + "</td>"
                            + "     <td align='center' style='padding:0 5px;'>" + formatCurrency(IsNull(json[o].Amount)) + "</td>"
                            + "     <td align='center'>"
                            + "         <input type='text' name='out_option[0][" + i + "]' value='0.00' />/"
                            + "         <input type='text' name='out_remark[0][" + i + "]' />"
                            + "     </td>"
                            + "     <td align='center'>"
                            + "         <input type='text' name='out_option[1][" + i + "]' value='0.00' />"
                            + "     </td>"
                            + "     <td align='center'>"
                            + "         <input type='text' name='out_option[2][" + i + "]' value='0.00' class='isFinanceConfirm'  />/"
                            + "         <input type='text' name='out_payee[2][" + i + "]' placeholder='请输入收款人' class='isFinanceConfirm'   />"
                            + "         <input type='text' name='out_account[2][" + i + "]' placeholder='请输入帐号'  class='isFinanceConfirm' />"
                            + "         <input type='text' name='out_bank[2][" + i + "]' placeholder='请输入银行名称' class='isFinanceConfirm' />"
                            + "     </td>"
                            + "     <td align='center'>"
                            + "         <input type='text' name='out_option[3][" + i + "]' value='0.00' />"
                            + "     </td>"
                            + "</tr>";
                        i++;
                    }
                    $("#out_tbody").html(html);
                    $("#hf_out_count").val(i);
                    $(".groupTable").tableUnGroup();
                    $(".groupTable").tableGroup({ groupColumn: 1 });
                    $.jBox.closeTip();

                    // 填写了退至客户银行账号，请默认勾选上“财务确认”
                    $(".out_groupTable :text.isFinanceConfirm").keyup(function () {
                        $("#cb_isFinanceConfirm").removeAttr("checked");
                        $(".out_groupTable :text.isFinanceConfirm").each(function () {
                            if (parseFloat($(this).val()) > 0) {
                                $("#cb_isFinanceConfirm").attr("checked", "checked");
                            }
                        });
                    });
                }
            });
        }
        /* 退款经销商回调方法 st */

        /* 进款经销商回调方法 st */
        function dealerInCallBack(dealerId) {
            $.jBox.tip('正在加载门店信息，请稍等...', 'loading');
            $.ajax({
                type: 'POST',
                url: '<%=Page.ResolveUrl("~/pages/smd/ajaxtools/handler.ashx?action=get_deposit_by_dealer")%>',
                data: { dealerid: dealerId },
                dataType: "json",
                cache: false,
                success: function (json) {
                    var html = "";
                    var i = 0;
                    for (var o in json) {
                        html += "<tr>"
                            + "     <td align='center' style='display:none'>[" + IsNull(json[o].AuthID) + "]" + IsNull(json[o].StoreName) + "</td>"
                            + "     <td align='center' style='width:40px;'>"
                            + "         <input type='checkbox' name='in_checked[" + i + "]' checked='checked' value='" + i + "' />"
                            + "         <input type='hidden' name='in_AuthID[" + i + "]' value='" + IsNull(json[o].AuthID) + "' />"
                            + "         <input type='hidden' name='in_StoreID[" + i + "]' value='" + IsNull(json[o].StoreID) + "' />"
                            + "         <input type='hidden' name='in_DeviceID[" + i + "]' value='" + IsNull(json[o].DeviceID) + "' />"
                            + "     </td>"
                            + "     <td align='center' style='width:110px;'>" + (IsNull(json[o].FullSetSN)) + "</td>"
                            + "     <td align='center' style='width:80px;'>" + formatCurrency(IsNull(json[o].Amount)) + "</td>"
                            + "     <td align='center'>"
                            + "         <input type='text' name='in_option[0][" + i + "]' value='0.00' />"
                            + "     </td>"
                            + "     <td align='center'>"
                            + "         <input type='text' name='in_option[1][" + i + "]' value='0.00' />/"
                            + "         <input type='text' name='in_remark[1][" + i + "]' />"
                            + "     </td>"
                            + "     <td align='center'>"
                            + "         <input type='text' name='in_option[2][" + i + "]' value='0.00' />"
                            + "     </td>"
                            + "</tr>";
                        i++;
                    }

                    $("#in_tbody").html(html);
                    $("#hf_in_count").val(i);
                    $(".groupTable").tableUnGroup();
                    $(".groupTable").tableGroup({ groupColumn: 1 });
                    $.jBox.closeTip();
                }
            });
        }
        /* 进款经销商回调方法 st */

        function IsNull(val) {
            return val == null ? "" : val;
        }
    </script>
</head>
<body>
    <div class="flowpage">
        <form id="form" runat="server">
            <input type="hidden" id="dealer_region_y" value="ddl_region" />
            <input type="hidden" id="dealer_province_y" value="ddl_province" />
            <asp:HiddenField ID="hf_in_count" runat="server" Value="0" />
            <asp:HiddenField ID="hf_out_count" runat="server" Value="0" />

            <!-- 标题 st -->
            <uc1:uc_head ID="uc_head1" runat="server" />
            <!-- 标题 ed -->
            <!-- 表单内容 st -->
            <div style="margin: 10px 0;">
                <table class="formTable">
                    <tbody>
                        <tr>
                            <td colspan="6" class="title">经销商选择范围</td>
                        </tr>
                        <tr>
                            <th style="width: 13%;">区域范围：</th>
                            <td colspan="5">
                                <asp:Literal ID="l_area" runat="server"></asp:Literal>
                                <asp:DropDownList ID="ddl_region" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddl_region_SelectedIndexChanged"></asp:DropDownList>
                                <asp:DropDownList ID="ddl_province" runat="server">
                                    <asp:ListItem Text="==请选择==" Value=""></asp:ListItem>
                                </asp:DropDownList>
                            </td>
                        </tr>
                    </tbody>

                    <!-- 退款经销商 st -->
                    <uc:uc_dealer ID="uc_dealer_out" runat="server" />
                    <!-- 退款经销商 st -->

                    <!-- 进款经销商 st -->
                    <uc:uc_dealer ID="uc_dealer_in" runat="server" />
                    <!-- 进款经销商 st -->

                    <tbody>
                        <tr>
                            <td class="title" colspan="6">退款列表<span style="color: #FF3366; font-weight: 100;">（给新经销商仅受理之前提供给Vivian的三方转移清单，其他概不受理）</span></td>
                        </tr>
                        <tr>
                            <td colspan="6">
                                <table class="groupTable out_groupTable" width="100%">
                                    <thead>
                                        <tr>
                                            <th align="center" style="display: none"></th>
                                            <%  // 只在第一步可以选择
                                                if (TaskAPI.IsBeginStep && TaskAPI.Step != "Submit Document" && AksRequest.GetString("readonly") != "1")
                                                { %>
                                            <th align="center" style="width: 40px;">选择</th>
                                            <%  } %>
                                            <%  if (TaskAPI.Step == "Submit Document")
                                                { %>

                                            <%  } %>
                                            <th align="center" style="width: 110px;">固定资产号</th>
                                            <th align="center" style="width: 80px; padding: 0 5px;">原保证金</th>
                                            <th align="center" style="width: 260px;">转营业外收入/备注</th>
                                            <th align="center" style="width: 130px;">退至客户货款账户</th>
                                            <th align="center" style="width: 330px;">退至客户银行账号/收款人/帐号/银行名称</th>
                                            <th align="center" style="width: 120px;">给新经销商</th>
                                            <%  if (!TaskAPI.IsBeginStep && TaskAPI.Step != "Submit Document")
                                                { %>
                                            <th align="center" style="width: 150px;">退款凭证号码</th>
                                            <%  } %>
                                        </tr>
                                    </thead>
                                    <tbody id="out_tbody" runat="server"></tbody>
                                </table>
                            </td>
                        </tr>
                        <tr runat="server" id="inTitle">
                            <td class="title" colspan="6">进款列表</td>
                        </tr>
                        <tr runat="server" id="inList">
                            <td colspan="6">
                                <table class="groupTable in_groupTable" width="100%">
                                    <thead>
                                        <tr>
                                            <th align="center" style="display: none"></th>
                                            <%  // 只在第一步可以选择
                                                if (TaskAPI.IsBeginStep && TaskAPI.Step != "Submit Document" && AksRequest.GetString("readonly") != "1")
                                                { %>
                                            <th align="center" style="width: 40px;">选择</th>
                                            <%  } %>
                                            <th align="center" style="width: 110px;">固定资产号</th>
                                            <th align="center" style="width: 80px;">原保证金</th>
                                            <th align="center" style="width: 250px;">汇入保证金</th>
                                            <th align="center" style="width: 320px;">汇入营业外收入/备注</th>
                                            <th align="center" style="width: 250px;">原经销商保证金转入</th>
                                            <%  if (!TaskAPI.IsBeginStep && TaskAPI.Step != "Submit Document")
                                                { %>
                                            <th align="center" style="width: 150px;">进款凭证号码</th>
                                            <%  } %>
                                        </tr>
                                    </thead>
                                    <tbody id="in_tbody" runat="server"></tbody>
                                </table>
                            </td>
                        </tr>
                    </tbody>

                    <%  // 只在第一步可以勾选
                        if (TaskAPI.IsBeginStep || TaskAPI.Step == "Submit Document")
                        { %>
                    <tr>
                        <th>退至客户银行账户必须选择财务确认：</th>
                        <td colspan="5">
                            <asp:CheckBox ID="cb_isFinanceConfirm" runat="server" Text="需要" />
                            <asp:Literal ID="l_isFinanceConfirm" runat="server"></asp:Literal>
                            <span style='margin-left: 5px; color: #FF3366;'>如需要退款至银行账户，请勾选并请上传DR2的邮件审批、工商局网站查询截屏及退款传票</span>
                        </td>
                    </tr>
                    <%  } %>
                    <tbody>
                        <tr>
                            <th>相关附件：</th>
                            <td colspan="5">
                                <uc:ajaxUpload ID="ajaxUpload1" runat="server" style="display: inline-block" />
                                <span style="color: red; display: inline-block">请将附件名称统一，例如‘调色机保证金、震荡机保证金、电脑保证金</span>
                            </td>
                        </tr>
                    </tbody>

                    <!-- 审批列表 st -->
                    <tbody id="assessment" runat="server" visible="false">
                        <tr>
                            <td class="title" colspan="6">审批列表</td>
                        </tr>
                        <tr>
                            <td colspan="6">
                                <uc:DwzAssessmentList ID="DwzAssessmentList1" runat="server" />
                            </td>
                        </tr>
                    </tbody>
                    <!-- 审批列表 ed -->

                    <!-- 审批意见 st -->
                    <uc:DwzAssessment ID="DwzAssessment1" runat="server" />
                    <!-- 审批意见 ed -->
                </table>
                <%  if (AksRequest.GetString("showbtn") != "0")
                    { %>
                <div style="margin: 5px; padding-bottom: 10px; text-align: center;">
                    <asp:Button ID="btn_submit" runat="server" CssClass="u-btn" Text="提交(Submit)" OnClick="btn_submit_Click" OnClientClick="return confirmSubmit();" />
                    <input type="button" class="u-btn u-btn-c4" onclick="custom_close()" value="关闭(Close)" />
                    <asp:HyperLink ID="hl_ExportPdf" runat="server" Visible="false" Target="_blank" CssClass="u-btn u-btn-c3" Style="height: 28px; line-height: 28px; display: inline-block;">生成(PDF)</asp:HyperLink>
                    <asp:Button ID="btn_print" runat="server" CssClass="u-btn u-btn-c2" Text="打印(Print)" OnClientClick="window.print()" Visible="false" />

                </div>
                <%  } %>
            </div>
            <!-- 表单内容 ed -->
        </form>
    </div>
</body>
</html>
